package com.xgpro.mapper.archives;

import com.xgpro.domain.archives.entity.RankApproval;
import com.xgpro.domain.archives.vo.Archives;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface RankApprovalMapper extends Mapper<RankApproval> {

    @Select("<script>" +
            " select id,username,user_id as userId, dept_name as deptName, upper_rank_name as upperRankName , next_rank_name as nextRankName," +
            " next_rank_id as nextRankId,status " +
            " from t_rank_approval" +
            "<where>" +
            " <if test=\"rankName != null and rankName !='' \"> " +
            "  and upper_rank_name like CONCAT('%',#{rankName},'%')" +
            " </if>" +
            " <if test=\"deptName != null and deptName!='' \"> " +
            "  and  dept_name like CONCAT('%',#{deptName},'%')" +
            " </if>" +
            " <if test=\"status != null \"> " +
            "  and status=#{status}  " +
            " </if>" +
            "</where>" +
            "order by creation_time DESC" +
            "</script>")
    List<RankApproval> selectBy(@Param("rankName")String rankName, @Param("deptName")String deptName, @Param("status")Integer status);



    @Select("<script>" +
            " select status " +
            " from t_rank_approval" +
            " where id in" +
            " <foreach collection='list' index='index' item='id'  open='(' separator=',' close=')'> " +
            "  #{id}" +
            " </foreach>" +
            "</script>")
    List<Integer> getStatus(List<Integer> ids);


    @Delete("<script>" +
            " delete from t_rank_approval where id in " +
            " <foreach collection='list' index='index' item='id'  open='(' separator=',' close=')'> " +
            "  #{id}" +
            " </foreach>" +
            " </script>")
    Integer beletes(List<Integer> ids);


}
